unit Class_Staf;

interface
uses
  Classes,SysUtils,Uni,UniEngine;

type
  TStaf=class(TUniEngine)
  private
    FUNITLINK: string;
    FSTAFIDEX: Integer;
    FSTAFBDID: Integer;
    FSTAFKJND: Integer;
    FSTAFKJQJ: Integer;
    FKJNDKJQJ: Integer;
    FDEPTLINK: string;
    FSTAFSEX: Integer;
    FSTAFTAX: Integer;
    FSTAFCODE: string;
    FSTAFWORK: string;
    FSTAFNAME: string;
    FSTAFCARD: string;
    FSTAFCALL: string;
    FSTAFMOBL: string;
    FSTAFORDR: Integer;
    FSTATCODE: Integer;
    FSTAFADDR: string;
    FSTAFMEMO: string;
    FSTAFSEAT: TDateTime;
    FSTAFQUIT: TDateTime;
    FSTAFBANK: string;
    FSTAFNUMB: string;
    FSTAFPROF: string;
    FSTAFPOST: string;
    FSTAFSTOP: Integer;
    FSTAFBASEDIGIT: Integer;
    FSTAFPROPDIGIT: Integer;
    FSTOPGZJG: string;
    FRECTLINK: string;
  protected
    procedure SetParameters;override;
    function  GetStrInsert:string;override;
    function  GetStrUpdate:string;override;
    function  GetStrDelete:string;override;
  public
    function  GetStrsIndex:string;override;
  public
    function  GetNextIdex:Integer;overload;
    function  GetNextIdex(AUniConnection:TUniConnection):Integer;overload;
  public
    function  CheckExist(AUniConnection:TUniConnection):Boolean;override;
  public
    destructor  Destroy; override;
    constructor Create;  
  published
    property UNITLINK: string read FUNITLINK write FUNITLINK;
    property STAFIDEX: Integer read FSTAFIDEX write FSTAFIDEX;
    property STAFBDID: Integer read FSTAFBDID write FSTAFBDID;
    property STAFKJND: Integer read FSTAFKJND write FSTAFKJND;
    property STAFKJQJ: Integer read FSTAFKJQJ write FSTAFKJQJ;
    property KJNDKJQJ: Integer read FKJNDKJQJ write FKJNDKJQJ;
    property DEPTLINK: string read FDEPTLINK write FDEPTLINK;
    property STAFSEX: Integer read FSTAFSEX write FSTAFSEX;
    property STAFTAX: Integer read FSTAFTAX write FSTAFTAX;
    property STAFCODE: string read FSTAFCODE write FSTAFCODE;
    property STAFWORK: string read FSTAFWORK write FSTAFWORK;
    property STAFNAME: string read FSTAFNAME write FSTAFNAME;
    property STAFCARD: string read FSTAFCARD write FSTAFCARD;
    property STAFCALL: string read FSTAFCALL write FSTAFCALL;
    property STAFMOBL: string read FSTAFMOBL write FSTAFMOBL;
    property STAFORDR: Integer read FSTAFORDR write FSTAFORDR;
    property STATCODE: Integer read FSTATCODE write FSTATCODE;
    property STAFADDR: string read FSTAFADDR write FSTAFADDR;
    property STAFMEMO: string read FSTAFMEMO write FSTAFMEMO;
    property STAFSEAT: TDateTime read FSTAFSEAT write FSTAFSEAT;
    property STAFQUIT: TDateTime read FSTAFQUIT write FSTAFQUIT;
    property STAFBANK: string read FSTAFBANK write FSTAFBANK;
    property STAFNUMB: string read FSTAFNUMB write FSTAFNUMB;
    property STAFPROF: string read FSTAFPROF write FSTAFPROF;
    property STAFPOST: string read FSTAFPOST write FSTAFPOST;
    property STAFSTOP: Integer read FSTAFSTOP write FSTAFSTOP;
    property STAFBASEDIGIT: Integer read FSTAFBASEDIGIT write FSTAFBASEDIGIT;
    property STAFPROPDIGIT: Integer read FSTAFPROPDIGIT write FSTAFPROPDIGIT;
    property STOPGZJG: string read FSTOPGZJG write FSTOPGZJG;
    property RECTLINK: string read FRECTLINK write FRECTLINK;    
  public
    class function  ReadDS(AUniQuery:TUniQuery):TUniEngine;override;
    class procedure ReadDS(AUniQuery:TUniQuery;var Result:TUniEngine);override;
    class function  CopyIt(ASTAF:TStaf):TStaf;overload;        
    class procedure CopyIt(ASTAF:TStaf;var Result:TStaf);overload;       
  end;

implementation

{ TStaf }
procedure TStaf.SetParameters;
begin
  inherited;
  with FUniSQL.Params do
  begin
    case FOptTyp of
      otAddx:
      begin
        ParamByName('UNIT_LINK').Value := UNITLINK;
        ParamByName('STAF_IDEX').Value := STAFIDEX;
        ParamByName('STAF_BDID').Value := STAFBDID;
        ParamByName('STAF_KJND').Value := STAFKJND;
        ParamByName('STAF_KJQJ').Value := STAFKJQJ;
        ParamByName('KJND_KJQJ').Value := KJNDKJQJ;
        ParamByName('DEPT_LINK').Value := DEPTLINK;
        ParamByName('STAF_SEX').Value := STAFSEX;
        ParamByName('STAF_TAX').Value := STAFTAX;
        ParamByName('STAF_CODE').Value := STAFCODE;
        ParamByName('STAF_WORK').Value := STAFWORK;
        ParamByName('STAF_NAME').Value := STAFNAME;
        ParamByName('STAF_CARD').Value := STAFCARD;
        ParamByName('STAF_CALL').Value := STAFCALL;
        ParamByName('STAF_MOBL').Value := STAFMOBL;
        ParamByName('STAF_ORDR').Value := STAFORDR;
        ParamByName('STAT_CODE').Value := STATCODE;
        ParamByName('STAF_ADDR').Value := STAFADDR;
        ParamByName('STAF_MEMO').Value := STAFMEMO;
        ParamByName('STAF_SEAT').Value := STAFSEAT;
        ParamByName('STAF_QUIT').Value := STAFQUIT;
        ParamByName('STAF_BANK').Value := STAFBANK;
        ParamByName('STAF_NUMB').Value := STAFNUMB;
        ParamByName('STAF_PROF').Value := STAFPROF;
        ParamByName('STAF_POST').Value := STAFPOST;
        ParamByName('STAF_STOP').Value := STAFSTOP;
        ParamByName('STAF_BASE_DIGIT').Value := STAFBASEDIGIT;
        ParamByName('STAF_PROP_DIGIT').Value := STAFPROPDIGIT;
        ParamByName('STOP_GZJG').Value := STOPGZJG;
        ParamByName('RECT_LINK').Value := RECTLINK; 
      end;
      otEdit:
      begin
        ParamByName('UNIT_LINK').Value := UNITLINK;
        ParamByName('STAF_IDEX').Value := STAFIDEX;
        ParamByName('STAF_BDID').Value := STAFBDID;
        ParamByName('STAF_KJND').Value := STAFKJND;
        ParamByName('STAF_KJQJ').Value := STAFKJQJ;
        ParamByName('KJND_KJQJ').Value := KJNDKJQJ;
        ParamByName('DEPT_LINK').Value := DEPTLINK;
        ParamByName('STAF_SEX').Value := STAFSEX;
        ParamByName('STAF_TAX').Value := STAFTAX;
        ParamByName('STAF_CODE').Value := STAFCODE;
        ParamByName('STAF_WORK').Value := STAFWORK;
        ParamByName('STAF_NAME').Value := STAFNAME;
        ParamByName('STAF_CARD').Value := STAFCARD;
        ParamByName('STAF_CALL').Value := STAFCALL;
        ParamByName('STAF_MOBL').Value := STAFMOBL;
        ParamByName('STAF_ORDR').Value := STAFORDR;
        ParamByName('STAT_CODE').Value := STATCODE;
        ParamByName('STAF_ADDR').Value := STAFADDR;
        ParamByName('STAF_MEMO').Value := STAFMEMO;
        ParamByName('STAF_SEAT').Value := STAFSEAT;
        ParamByName('STAF_QUIT').Value := STAFQUIT;
        ParamByName('STAF_BANK').Value := STAFBANK;
        ParamByName('STAF_NUMB').Value := STAFNUMB;
        ParamByName('STAF_PROF').Value := STAFPROF;
        ParamByName('STAF_POST').Value := STAFPOST;
        ParamByName('STAF_STOP').Value := STAFSTOP;
        ParamByName('STAF_BASE_DIGIT').Value := STAFBASEDIGIT;
        ParamByName('STAF_PROP_DIGIT').Value := STAFPROPDIGIT;
        ParamByName('STOP_GZJG').Value := STOPGZJG;
        ParamByName('RECT_LINK').Value := RECTLINK; 
      end;  
      otDelt:
      begin
        ParamByName('UNIT_LINK').Value := UNITLINK;
        ParamByName('STAF_IDEX').Value := STAFIDEX;
        ParamByName('STAF_BDID').Value := STAFBDID;
 
      end;  
    end;
  end;
end;

function TStaf.CheckExist(AUniConnection: TUniConnection): Boolean;
begin
  Result:=CheckExist('TBL_STAF',['UNIT_LINK',UNITLINK,'STAF_IDEX',STAFIDEX,'STAF_BDID',STAFBDID],AUniConnection);
end;

function TStaf.GetNextIdex: Integer;
begin

end;

function TStaf.GetNextIdex(AUniConnection: TUniConnection): Integer;
begin

end;

function TStaf.GetStrDelete: string;
begin
  Result:='DELETE FROM TBL_STAF WHERE   UNIT_LINK=:UNIT_LINK AND STAF_IDEX=:STAF_IDEX AND STAF_BDID=:STAF_BDID';
end;

function TStaf.GetStrInsert: string;
begin
  Result:='INSERT INTO TBL_STAF'
         +'    ( UNIT_LINK, STAF_IDEX, STAF_BDID, STAF_KJND, STAF_KJQJ'
         +'    , KJND_KJQJ, DEPT_LINK, STAF_SEX, STAF_TAX, STAF_CODE'
         +'    , STAF_WORK, STAF_NAME, STAF_CARD, STAF_CALL, STAF_MOBL'
         +'    , STAF_ORDR, STAT_CODE, STAF_ADDR, STAF_MEMO, STAF_SEAT'
         +'    , STAF_QUIT, STAF_BANK, STAF_NUMB, STAF_PROF, STAF_POST'
         +'    , STAF_STOP, STAF_BASE_DIGIT, STAF_PROP_DIGIT, STOP_GZJG'
         +'    , RECT_LINK)'
         +'    VALUES'
         +'    (:UNIT_LINK,:STAF_IDEX,:STAF_BDID,:STAF_KJND,:STAF_KJQJ'
         +'    ,:KJND_KJQJ,:DEPT_LINK,:STAF_SEX,:STAF_TAX,:STAF_CODE'
         +'    ,:STAF_WORK,:STAF_NAME,:STAF_CARD,:STAF_CALL,:STAF_MOBL'
         +'    ,:STAF_ORDR,:STAT_CODE,:STAF_ADDR,:STAF_MEMO,:STAF_SEAT'
         +'    ,:STAF_QUIT,:STAF_BANK,:STAF_NUMB,:STAF_PROF,:STAF_POST'
         +'    ,:STAF_STOP,:STAF_BASE_DIGIT,:STAF_PROP_DIGIT,:STOP_GZJG'
         +'    ,:RECT_LINK)';
end;

function TStaf.GetStrsIndex: string;
begin
  Result:=Format('%S-%D-%D',[UNITLINK,STAFIDEX,STAFBDID]);
end;

function TStaf.GetStrUpdate: string;
begin
  Result:='UPDATE  TBL_STAF SET'
         +'    STAF_KJND=:STAF_KJND,'
         +'    STAF_KJQJ=:STAF_KJQJ,'
         +'    KJND_KJQJ=:KJND_KJQJ,'
         +'    DEPT_LINK=:DEPT_LINK,'
         +'    STAF_SEX=:STAF_SEX,'
         +'    STAF_TAX=:STAF_TAX,'
         +'    STAF_CODE=:STAF_CODE,'
         +'    STAF_WORK=:STAF_WORK,'
         +'    STAF_NAME=:STAF_NAME,'
         +'    STAF_CARD=:STAF_CARD,'
         +'    STAF_CALL=:STAF_CALL,'
         +'    STAF_MOBL=:STAF_MOBL,'
         +'    STAF_ORDR=:STAF_ORDR,'
         +'    STAT_CODE=:STAT_CODE,'
         +'    STAF_ADDR=:STAF_ADDR,'
         +'    STAF_MEMO=:STAF_MEMO,'
         +'    STAF_SEAT=:STAF_SEAT,'
         +'    STAF_QUIT=:STAF_QUIT,'
         +'    STAF_BANK=:STAF_BANK,'
         +'    STAF_NUMB=:STAF_NUMB,'
         +'    STAF_PROF=:STAF_PROF,'
         +'    STAF_POST=:STAF_POST,'
         +'    STAF_STOP=:STAF_STOP,'
         +'    STAF_BASE_DIGIT=:STAF_BASE_DIGIT,'
         +'    STAF_PROP_DIGIT=:STAF_PROP_DIGIT,'
         +'    STOP_GZJG=:STOP_GZJG,'
         +'    RECT_LINK=:RECT_LINK'
         +'    WHERE UNIT_LINK=:UNIT_LINK'
         +'    AND   STAF_IDEX=:STAF_IDEX'
         +'    AND   STAF_BDID=:STAF_BDID';
end;

constructor TStaf.Create;
begin

end;

destructor TStaf.Destroy;
begin

  inherited;
end;

class function TStaf.ReadDS(AUniQuery: TUniQuery): TUniEngine;
begin
  Result:=TStaf.Create;
  with TStaf(Result) do
  begin
    UNITLINK:=AUniQuery.FieldByName('UNIT_LINK').AsString;
    STAFIDEX:=AUniQuery.FieldByName('STAF_IDEX').AsInteger;
    STAFBDID:=AUniQuery.FieldByName('STAF_BDID').AsInteger;
    STAFKJND:=AUniQuery.FieldByName('STAF_KJND').AsInteger;
    STAFKJQJ:=AUniQuery.FieldByName('STAF_KJQJ').AsInteger;
    KJNDKJQJ:=AUniQuery.FieldByName('KJND_KJQJ').AsInteger;
    DEPTLINK:=AUniQuery.FieldByName('DEPT_LINK').AsString;
    STAFSEX:=AUniQuery.FieldByName('STAF_SEX').AsInteger;
    STAFTAX:=AUniQuery.FieldByName('STAF_TAX').AsInteger;
    STAFCODE:=AUniQuery.FieldByName('STAF_CODE').AsString;
    STAFWORK:=AUniQuery.FieldByName('STAF_WORK').AsString;
    STAFNAME:=AUniQuery.FieldByName('STAF_NAME').AsString;
    STAFCARD:=AUniQuery.FieldByName('STAF_CARD').AsString;
    STAFCALL:=AUniQuery.FieldByName('STAF_CALL').AsString;
    STAFMOBL:=AUniQuery.FieldByName('STAF_MOBL').AsString;
    STAFORDR:=AUniQuery.FieldByName('STAF_ORDR').AsInteger;
    STATCODE:=AUniQuery.FieldByName('STAT_CODE').AsInteger;
    STAFADDR:=AUniQuery.FieldByName('STAF_ADDR').AsString;
    STAFMEMO:=AUniQuery.FieldByName('STAF_MEMO').AsString;
    STAFSEAT:=AUniQuery.FieldByName('STAF_SEAT').AsDateTime;
    STAFQUIT:=AUniQuery.FieldByName('STAF_QUIT').AsDateTime;
    STAFBANK:=AUniQuery.FieldByName('STAF_BANK').AsString;
    STAFNUMB:=AUniQuery.FieldByName('STAF_NUMB').AsString;
    STAFPROF:=AUniQuery.FieldByName('STAF_PROF').AsString;
    STAFPOST:=AUniQuery.FieldByName('STAF_POST').AsString;
    STAFSTOP:=AUniQuery.FieldByName('STAF_STOP').AsInteger;
    STAFBASEDIGIT:=AUniQuery.FieldByName('STAF_BASE_DIGIT').AsInteger;
    STAFPROPDIGIT:=AUniQuery.FieldByName('STAF_PROP_DIGIT').AsInteger;
    STOPGZJG:=AUniQuery.FieldByName('STOP_GZJG').AsString;
    RECTLINK:=AUniQuery.FieldByName('RECT_LINK').AsString;
  end;  
end;

class procedure TStaf.ReadDS(AUniQuery: TUniQuery; var Result: TUniEngine);
begin
  if Result=nil then Exit;
  with TStaf(Result) do
  begin
    UNITLINK:=AUniQuery.FieldByName('UNIT_LINK').AsString;
    STAFIDEX:=AUniQuery.FieldByName('STAF_IDEX').AsInteger;
    STAFBDID:=AUniQuery.FieldByName('STAF_BDID').AsInteger;
    STAFKJND:=AUniQuery.FieldByName('STAF_KJND').AsInteger;
    STAFKJQJ:=AUniQuery.FieldByName('STAF_KJQJ').AsInteger;
    KJNDKJQJ:=AUniQuery.FieldByName('KJND_KJQJ').AsInteger;
    DEPTLINK:=AUniQuery.FieldByName('DEPT_LINK').AsString;
    STAFSEX:=AUniQuery.FieldByName('STAF_SEX').AsInteger;
    STAFTAX:=AUniQuery.FieldByName('STAF_TAX').AsInteger;
    STAFCODE:=AUniQuery.FieldByName('STAF_CODE').AsString;
    STAFWORK:=AUniQuery.FieldByName('STAF_WORK').AsString;
    STAFNAME:=AUniQuery.FieldByName('STAF_NAME').AsString;
    STAFCARD:=AUniQuery.FieldByName('STAF_CARD').AsString;
    STAFCALL:=AUniQuery.FieldByName('STAF_CALL').AsString;
    STAFMOBL:=AUniQuery.FieldByName('STAF_MOBL').AsString;
    STAFORDR:=AUniQuery.FieldByName('STAF_ORDR').AsInteger;
    STATCODE:=AUniQuery.FieldByName('STAT_CODE').AsInteger;
    STAFADDR:=AUniQuery.FieldByName('STAF_ADDR').AsString;
    STAFMEMO:=AUniQuery.FieldByName('STAF_MEMO').AsString;
    STAFSEAT:=AUniQuery.FieldByName('STAF_SEAT').AsDateTime;
    STAFQUIT:=AUniQuery.FieldByName('STAF_QUIT').AsDateTime;
    STAFBANK:=AUniQuery.FieldByName('STAF_BANK').AsString;
    STAFNUMB:=AUniQuery.FieldByName('STAF_NUMB').AsString;
    STAFPROF:=AUniQuery.FieldByName('STAF_PROF').AsString;
    STAFPOST:=AUniQuery.FieldByName('STAF_POST').AsString;
    STAFSTOP:=AUniQuery.FieldByName('STAF_STOP').AsInteger;
    STAFBASEDIGIT:=AUniQuery.FieldByName('STAF_BASE_DIGIT').AsInteger;
    STAFPROPDIGIT:=AUniQuery.FieldByName('STAF_PROP_DIGIT').AsInteger;
    STOPGZJG:=AUniQuery.FieldByName('STOP_GZJG').AsString;
    RECTLINK:=AUniQuery.FieldByName('RECT_LINK').AsString;
  end;  
end;

class function  TStaf.CopyIt(ASTAF: TStaf): TStaf;
begin
  Result:=TStaf.Create;
  TStaf.CopyIt(ASTAF,Result)
end;

class procedure TStaf.CopyIt(ASTAF:TStaf;var Result:TStaf);
begin
  if Result=nil then Exit;
  Result.UNITLINK:=ASTAF.UNITLINK;
  Result.STAFIDEX:=ASTAF.STAFIDEX;
  Result.STAFBDID:=ASTAF.STAFBDID;
  Result.STAFKJND:=ASTAF.STAFKJND;
  Result.STAFKJQJ:=ASTAF.STAFKJQJ;
  Result.KJNDKJQJ:=ASTAF.KJNDKJQJ;
  Result.DEPTLINK:=ASTAF.DEPTLINK;
  Result.STAFSEX:=ASTAF.STAFSEX;
  Result.STAFTAX:=ASTAF.STAFTAX;
  Result.STAFCODE:=ASTAF.STAFCODE;
  Result.STAFWORK:=ASTAF.STAFWORK;
  Result.STAFNAME:=ASTAF.STAFNAME;
  Result.STAFCARD:=ASTAF.STAFCARD;
  Result.STAFCALL:=ASTAF.STAFCALL;
  Result.STAFMOBL:=ASTAF.STAFMOBL;
  Result.STAFORDR:=ASTAF.STAFORDR;
  Result.STATCODE:=ASTAF.STATCODE;
  Result.STAFADDR:=ASTAF.STAFADDR;
  Result.STAFMEMO:=ASTAF.STAFMEMO;
  Result.STAFSEAT:=ASTAF.STAFSEAT;
  Result.STAFQUIT:=ASTAF.STAFQUIT;
  Result.STAFBANK:=ASTAF.STAFBANK;
  Result.STAFNUMB:=ASTAF.STAFNUMB;
  Result.STAFPROF:=ASTAF.STAFPROF;
  Result.STAFPOST:=ASTAF.STAFPOST;
  Result.STAFSTOP:=ASTAF.STAFSTOP;
  Result.STAFBASEDIGIT:=ASTAF.STAFBASEDIGIT;
  Result.STAFPROPDIGIT:=ASTAF.STAFPROPDIGIT;
  Result.STOPGZJG:=ASTAF.STOPGZJG;
  Result.RECTLINK:=ASTAF.RECTLINK;
end;

end.

